<?php
/* @var $this BackendController */
/* @var $model Article */

$this->breadcrumbs=array(
    Yii::t('ArticleModule.base','Articles')=>array('index'),
    Yii::t('ArticleModule.base','Manage'),
);
$this->menu=array(
    array('label'=>'<span class="glyphicon glyphicon-plus"></span>&nbsp'.Yii::t('ArticleModule.base','Create Article'), 'url'=>array('create')),
    array('label'=>'<span class="glyphicon glyphicon-cog"></span>&nbsp'.Yii::t('ArticleModule.base','List Article'), 'url'=>array('index')),
);


Yii::app()->clientScript->registerPackage('fancybox');
Yii::app()->clientScript->registerScript('search', "
    $('.fancybox').fancybox();
    $('.glyphicon, img').tooltip();
    $('.btn-primary').tooltip({container:'body'});

    $('.search-button').click(function(){
        $('.search-form').toggle();
        return false;
    });
    $('.search-form form').submit(function(){
        $('#article-grid').yiiGridView('update', {
            data: $(this).serialize()
        });
        return false;
    });
    $('#refresh').on('click',function(e){
        $.fn.yiiGridView.update('article-grid');
    });
");
?>
<div class="panel panel-primary">
    <div class="panel-heading">
        <i class="fa fa-cogs"></i><span class="h4"><?php echo Yii::t('ArticleModule.base','Manage Article')?></span><a id="refresh" class="alignRight white font16" href="#"><i class="fa fa-refresh"></i></a>
    </div>
    <div class="panel-body">
            <div class="search-form">
                <?php $this->renderPartial('_search',array(
                    'model'=>$model,
                )); ?>
            </div><!-- search-form -->

        <?php $this->widget('zii.widgets.grid.CGridView', array(
            'id'=>'article-grid',
            'dataProvider'=>$model->search(),
           // 'filter'=>$model,
            'pager' => array('cssFile' => Yii::app()->theme->baseUrl . '/assets/gridview/pager.css'),
            'baseScriptUrl'=>Yii::app()->theme->baseUrl.'/assets/gridview',
            //'ajaxType'=>'POST',
            //'ajaxUpdate'=>'true',

            'columns'=>array(

                array(
                    'name'=>'id',
                    'type' => 'raw',
                    'value'=>'CHtml::tag("span",array("class"=>"badge"),$data->id)',
                    'htmlOptions' => array('style'=>'width:10px'),
                ),
                array(
                    'name' => 'image',
                    'type' => 'raw',
                    'value' => '$data->getImageForGrid()',
                    'htmlOptions' => array('style'=>'width:100px'),
                ),
                array(
                    'name'=>'title',
                    'type' => 'raw',
                    'value'=>'CHtml::link($data->title,Yii::app()->createUrl("/article/backend/view",array("id"=>"$data->id")))',
                    'htmlOptions' => array('style'=>'width:30px'),
                ),
                array(
                    'name'=>'category_id',
                    'type' => 'raw',
                    'value'=>'$data->getCategoryName()',
                    'htmlOptions' => array('style'=>'width:30px'),
                ),
                array(
                    'name'=>'create_time',
                    'type'=>'raw',
                    'value'=>'$data->getCreateDateTimeFormat()',
                    'htmlOptions' => array('style'=>'width:100px'),
                ),
                array(
                    'name'=>'update_time',
                    'type'=>'raw',
                    'value'=>'$data->getUpdateDateTimeFormat()',
                    'htmlOptions' => array('style'=>'width:100px'),
                ),
                array(
                    'name'=>'status',
                    'type' => 'raw',
                    'value'=>'$data->getArticleStatus()',
                    'htmlOptions' => array('style'=>'width:30px'),

                ),

                array(
                    'class'=>'CButtonColumn',
                    'htmlOptions' => array('style'=>'width:50px;font-size:20px'),
                    'template'=>'{view}  {update}  {delete}',
                    //  'viewButtonOptions'=>array('class'=>'glyphicon glyphicon-eye-open','style'=>'padding-right:5px'),
                    //  'updateButtonOptions'=>array('class'=>'glyphicon glyphicon-edit','style'=>'padding-right:5px'),
                    //  'deleteButtonOptions'=>array('class'=>'glyphicon glyphicon-trash','style'=>'padding-right:5px'),
                    'buttons'=>array(
                        'view'=>array(
                            'label'=>'',
                            'imageUrl'=>'',
                            'options'=>array('class'=>'glyphicon glyphicon-eye-open','style'=>'padding-right:5px','data-toggle'=>'tooltip','title'=>Yii::t('MenuModule.base','View')),
                        ),
                        'update'=>array(
                            'label'=>'',
                            'imageUrl'=>'',
                            'options'=>array('class'=>'glyphicon glyphicon-edit','style'=>'padding-right:5px','data-toggle'=>'tooltip','title'=>Yii::t('MenuModule.base','Edit')),
                        ),
                        'delete'=>array(
                            'label'=>'',
                            'imageUrl'=>'',
                            'options'=>array('class'=>'glyphicon glyphicon-trash','style'=>'padding-right:5px','data-toggle'=>'tooltip','title'=>Yii::t('MenuModule.base','Delete')),
                        ),
                    )
                ),
            ),
        )); ?>
    </div>
    <div class="panel-footer">
    </div>
</div>